<?php 
/**
 * This file is part of DomMonitor.
 * 
 * DomMonitor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * DomMonitor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with DomMonitor.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @link http://inditel.ee/
 * @copyright 2007-2009 Inditel Meedia OÜ
 * @author Oliver Leisalu <oliver@inditel.ee>
 */

/**
* @author Oliver Leisalu, Inditel Meedia OÜ
* @package DomMonitor
*/
class DomMonitorableExample implements DomMonitorable {
	
	/**
	 * @var Bool
	 */
	public static $monitor = false;
	/**
	 * @var Array
	 */
	public static $monitorData;

	public function __construct() {
		// set monitor ON or OFF. This global variable is set to true, if monitor is active.
		self::$monitor = &$GLOBALS['DomMonitorActive'];
	}
	
	public static function doSomethingThatShouldBeMonitored() {

		if( self::$monitor === true ) $time = microtime(true);
			
		// do something
		$a = 2;
		for( $i=0; $i<64; $i++) {
			$a*=$a;
		}
		
		if( self::$monitor === true ) 
			self::$monitorData[] = new DomMonitorEntry( $time, microtime(true), 'Action description');

	}
	
	public static function getMonitorData() {
		return self::$monitorData;
	}
}
?>